package view;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.stage.StageStyle;

import java.io.IOException;

/**
 * 自定义提示框窗口PromptBoxView
 * 用于弹出各种提示
 */
public class PBoxView extends Window{

    public PBoxView(String tips) throws IOException {
        root = FXMLLoader.load(getClass().getClassLoader().getResource("pBox.fxml"));
        Scene scene = new Scene(root, 450, 250);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        initStyle(StageStyle.TRANSPARENT);
        setResizable(false);
        setTitle("Prompt");
        move();
        quit();
        minimize();
        setTips(tips);
    }

    @Override
    public void quit() {
        ((Button)findViewById("quit")).setOnAction(event -> {
            close();
        });
    }

    @Override
    public void minimize() {
        ((Button)findViewById("min")).setOnAction(event -> {
            setIconified(true);
        });
    }

    public void setTips(String tips) {
        ((Label)findViewById("info")).setText(tips);
    }
}
